Skip to content

fix: solve #3504 — clear WebGL texture atlas on terminal reattach/resize#3505

Draft
github-actions[bot] wants to merge 1 commit intomainfrom
triage/issue-3504-24511179713
Draft

fix: solve #3504 — clear WebGL texture atlas on terminal reattach/resize#3505
github-actions[bot] wants to merge 1 commit intomainfrom
triage/issue-3504-24511179713

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot commented Apr 16, 2026

Summary

  • Root cause: When a cached terminal is reattached to a DOM container (tab switch, pane focus) or resized, attachToContainer in v1-terminal-cache.ts calls xterm.refresh() but never clears the WebGL texture atlas. Stale glyph textures from the previous rendering context persist, causing garbled text and background terminal content ghosting into the chat view on macOS.
  • Fix: Expose clearTextureAtlas() from the xterm WebglAddon via createTerminalInWrapper() in helpers.ts, store it in CachedTerminal, and call it in attachToContainer before refresh() and in the ResizeObserver callback when dimensions change. This forces the WebGL renderer to rebuild its glyph texture from scratch on every reattach/resize, eliminating stale rendering artifacts.
  • Test: Added v1-terminal-cache.test.ts with 5 tests that model the attach/resize logic and verify clearTextureAtlas is called at the right times (before refresh on reattach, on resize when dimensions change, not on no-op resize).

Test plan

  • bun test apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/ — all 73 tests pass (including 5 new)
  • bun run lint:fix — passes clean
  • Manual verification on macOS: open multiple terminal panes, switch tabs, resize window — no garbled text or ghosting

Closes #3504


Summary by cubic

Fixes issue #3504 by clearing the xterm WebGL texture atlas when a cached terminal is reattached or resized. This removes stale glyphs and prevents garbled text and ghosting on macOS.

  • Bug Fixes
    • Expose clearTextureAtlas from WebglAddon via createTerminalInWrapper, store on CachedTerminal.
    • Call clearTextureAtlas() in attachToContainer before refresh() and on ResizeObserver dimension changes.
    • Add 5 tests covering reattach, resize, call order, and no-op resize.

Written for commit 09b38ac. Summary will update on new commits.

Stale glyph textures in the xterm WebGL addon cause garbled rendering
and ghosting on macOS when a cached terminal is reattached to a DOM
container (tab switch) or resized. Expose clearTextureAtlas() from the
WebGL addon and call it in attachToContainer before refresh, and in the
ResizeObserver when dimensions change. Refs xtermjs/xterm.js#3303.

Closes #3504
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] macOS terminal rendering can corrupt and ghost into chat until fullscreen toggle

0 participants